package com.xj.controller;

import com.xj.server.DatabaseBackService;
import com.xj.server.ExecuteCommandServer;
import com.xj.server.ReadfileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@ResponseBody
@RestController
public class SystemManagerController {
    @Autowired
    private ReadfileService readfileService;
    @Autowired
    private ExecuteCommandServer executeCommandServer;
    @Autowired
    private DatabaseBackService databaseBackService;

    @GetMapping(value = "/file")
    public @ResponseBody
    String generateFile() throws Exception {
        readfileService.outputFile();
        return "generateFile";
    }

    @GetMapping(value = "/restart")
    public @ResponseBody
    String restartServer() throws Exception {
        executeCommandServer.executRestart();
        return "restartServer";
    }


    @GetMapping(value = "/back")
    public @ResponseBody
    String back() throws Exception {
        databaseBackService.executeBack();
        return "back Database";
    }



}
